/**
 * \* Created with IntelliJ IDEA.
 * \* User: Administrator
 * \* Date: 2021/11/28
 * \* Time: 20:06
 * \* To change this template use File | Settings | File Templates.
 * \* Description:
 * \
 */

class NameException extends RuntimeException{
    public NameException(String message){
        super(message);
    }
}
class PasswordException extends RuntimeException{
    public PasswordException(String message){
        super(message);
    }
}
public class TestDemo2 {
    private static final String name="mrzhu";
    private static final String password="1230";

    public static  void login(String name,String password) throws NameException,PasswordException{
        if(!TestDemo2.name.equals(name)){
            throw new NameException("用户名错误！");
        }
        if (!TestDemo2.password.equals(password)){
            throw new PasswordException("密码错误");
        }
    }
    public static void main(String[] args) {
        try {
            login("mrzhu","1235");
        }catch (NameException e){
            e.printStackTrace();
            System.out.println("用户名错误！");
        }catch (PasswordException e){
            e.printStackTrace();
            System.out.println("密码错误！");
        }finally {
            System.out.println("finally执行了！");
        }
    }
}
